package cn.itrip.auth.service;

import com.cloopen.rest.sdk.CCPRestSmsSDK;
import org.springframework.stereotype.Service;

import java.util.HashMap;

@Service
public class SmsServiceImpl implements SmsService{
    @Override
    public void send(String to, String templateId, String[] datas) throws Exception {
        CCPRestSmsSDK smsSDK=new CCPRestSmsSDK();
        //初始化短信服务器
        smsSDK.init("app.cloopen.com","8883");
        smsSDK.setAccount("8a216da87d46c5ba017d513199de039f","c630bce2a6024ede85dc494db90a1592");
        smsSDK.setAppId("8a216da87d46c5ba017d51319ad103a6");
        HashMap hashMap=smsSDK.sendTemplateSMS(to, templateId, datas);
        if("000000".equals(hashMap.get("statusCode")))
            System.out.println("短信发送成功");
        else
            throw new Exception(hashMap.get("statusCode").toString()+":"+hashMap.get("statusMsg").toString());
    }

}
